export default {
    data () {
        return {
            hasNext:null,
           path:"" ,
           hidden:false
        }
    },
    watch: {
        $route:{
            handler(val,oldval){
                console.log("老路由信息",oldval.path);//老路由信息
                if(oldval.path == "/"){
                    this.hasNext = false
                }else{
                    this.hasNext = true
                }
            },
            // 深度观察监听
            deep: true
        }
    },
    mounted(){
        this.listenerFunction();
    },
    beforeDestroy () {
      document.removeEventListener("scroll", this.listenerFunction);
    },
    methods: {
        onClickLeft(){
            if(this.hasNext == true){
                this.$router.go(-1)
            }else{
                this.$router.push("/allmessage")
            }
        },
        // 关键字搜索
        onSearch(){
            this.loadData()
        },
        // 下拉监听开始
        listenerFunction(e) {
            document.addEventListener('scroll', this.handleScroll, true);
        },
        handleScroll () {
            var scroll = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
            // console.log(scroll)
            if(scroll>=200){
                this.hidden = true
            }else{
                this.hidden = false
            }
        },
        // 下拉监听结束
    }
}